package spe.model.spem;

import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.draw2d.geometry.Point;
import spe.model.notation.Link;
import spe.model.notation.SPEMDiagram;

public class NodeElementImpl extends SPEMElementImpl implements NodeElement
{
	private SPEMDiagram container;
	private Point position = new Point(0, 0);
	private List<Link> leavingEdges = new ArrayList<Link>();
	private List<Link> arrivingEdges = new ArrayList<Link>();
	
	public void setPosition(Point newPos) 
	{
		Point oldPos = position;
		this.position = newPos;
		firePropertyChange("Position", oldPos, newPos);
	}
	
	public Point getPosition() 
	{
		return position;
	}
	
	public void addLeavingEdge(Link edge) 
	{
		leavingEdges.add(edge);
		edge.setSource(this);
		//firePropertyChange("leavingEdgeAdd", null, edge);
	}
	
	public void removeLeavingEdge(Link edge)
	{
		leavingEdges.remove(edge);
		edge.setSource(null);
		firePropertyChange("leavingEdgeRemove", null, edge);
	}
	
	public List<Link> getLeavingEdges() 
	{
		return leavingEdges;
	}

	public void addArrivingEdge(Link edge) 
	{
		arrivingEdges.add(edge);
		edge.setTarget(this);
		//firePropertyChange("arrivingEdgeAdd", null, edge);
	}
	
	public void removeArrivingEdge(Link edge)
	{
		arrivingEdges.remove(edge);
		edge.setTarget(null);
		firePropertyChange("arrivingEdgeRemove", null, edge);
	}
	
	public List<Link> getArrivingEdges()
	{
		return arrivingEdges;
	}
	
	public void setContainer(SPEMDiagram notationElement) 
	{
		this.container = notationElement;
	}
	
	public  SPEMDiagram getContainer()
	{
		return container;
	}

	@Override
	public void propertyChange(PropertyChangeEvent evt)
	{	
	}

}
